import { addType, delType, getType, changeType } from "../../api/classType"

const state = {
    classtype: []
}

const mutations = {
    ADD_TYPE(state, payload) {
        state.classtype.push(payload)
    },
    SET_TYPE1(state, payload) {
        state.classtype = payload
    }
}

const actions = {
    async addType({ commit }, typeInfo) {
        let res = await addType(typeInfo)
        commit("ADD_TYPE", res.data)
    },
    async getType({ commit }) {
        let res = await getType();
        commit("SET_TYPE1", res.data)
    },
    async delType({ commit }, id) {
        await delType(id)
        return {
            code: 200,
            msg: "删除成功"
        }
    }
}

export default {
    state,
    mutations,
    actions
}